import store from 'hhlt-vue/src/store/index'

// https://webpack.js.org/guides/dependency-management/#requirecontext
const modulesFiles = require.context('./modules', true, /\.ts$/)

console.log("获取到的vuex配置信息为：",modulesFiles)
// you do not need `import app from './modules/app'`
// it will auto require all vuex module from modules file
const buildModules = modulesFiles.keys().filter(item => item.indexOf('permission') < 0).reduce((modules, modulePath) => {
  // set './app.js' => 'app'
  debugger
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const value = modulesFiles(modulePath)

  // 注册嵌套模块 `nested/myModule`
  // store.unregisterModule(moduleName)
  store.registerModule(moduleName, value.default)
  Object.defineProperties(modules,{
    moduleName:{
      configurable:true,
      enumerable:true, //tel属性修改为可枚举
      value:value.default
    },
  })

  return modules
  // }
}, {})

export default store
